package com.zt.controller;

import com.zt.common.Result;
import com.zt.pojo.RolePermissions;
import com.zt.service.RolePermissionsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api")
public class RolePermissionController {
    @Autowired
    private RolePermissionsService rolePermissionsService;
    @PostMapping("/role_permissions")
    public Result addPersmission(@RequestBody RolePermissions rolePermissions){
        boolean save = rolePermissionsService.save(rolePermissions);
        return save?Result.OK():Result.ERROR();
    }

    @DeleteMapping("/role_permissions/{role_id}/{permission_id}")
    public Result deletePermission(@PathVariable Integer role_id,@PathVariable Integer permission_id){
        return rolePermissionsService.delete(role_id,permission_id);
    }
}
